package com.bytenebula.asteroid.config;

import io.lettuce.core.ClientOptions;
import io.lettuce.core.protocol.ProtocolVersion;
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.autoconfigure.data.redis.LettuceClientConfigurationBuilderCustomizer;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;

@Configuration
public class LettuceConfig
        implements LettuceClientConfigurationBuilderCustomizer {

    /**
     * Customize the {@link LettuceClientConfigurationBuilder}.
     *
     * @param clientConfigurationBuilder the builder to customize
     */
    @Override
    public void customize(LettuceClientConfiguration.LettuceClientConfigurationBuilder clientConfigurationBuilder) {
        clientConfigurationBuilder
                .clientOptions(ClientOptions.builder()
                .protocolVersion(ProtocolVersion.RESP2)
                        .build());
    }
}
